Add a build option for the GResource fast-path, and disable it
authorSimon McVittie <smcv@debian.org>
Mon, 15 Aug 2022 21:27:14 +0000 (22:27 +0100)
committerSimon McVittie <smcv@debian.org>
Tue, 16 Aug 2022 07:22:07 +0000 (08:22 +0100)
For an incremental developer build, it's annoying if GResource
processing takes longer than it needed to, but for a distro build where
we're compiling all of GTK, the time taken to process GResource data
is less significant and the cost of resolving a broken build is higher.

debian/patches/build-Add-an-option-to-use-more-conservative-GResource-em.patch [new file with mode: 0644]
debian/patches/series
debian/rules

diff --git a/debian/patches/build-Add-an-option-to-use-more-conservative-GResource-em.patch b/debian/patches/build-Add-an-option-to-use-more-conservative-GResource-em.patch
new file mode 100644 (file)
index 0000000..311aca8
--- /dev/null
@@ -0,0 +1,72 @@
+From: Simon McVittie <smcv@debian.org>
+Date: Mon, 15 Aug 2022 22:24:26 +0100
+Subject: build: Add an option to use more conservative GResource embedding
+
+Doing clever things with objcopy is faster, but also doesn't work on
+all toolchains and architectures: in particular, Debian has had trouble
+with this on arm and mips.
+
+Developers will want to leave this option switched on for faster
+incremental builds (unless their toolchain doesn't support it), but in
+a distro build environment where we are compiling all of GTK every time,
+the cost of potentially unreliable builds is higher than the cost of
+using slower but more conservative GResource embedding.
+
+Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/5107
+Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4956
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ gtk/meson.build   | 15 ++++++++++++++-
+ meson_options.txt |  5 +++++
+ 2 files changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/gtk/meson.build b/gtk/meson.build
+index 2e404f2..46f886f 100644
+--- a/gtk/meson.build
++++ b/gtk/meson.build
+@@ -866,15 +866,28 @@ if not fs.exists('theme/Default/Default-light.css')
+ endif
++fast_gresource_embedding = get_option('fast_gresource_embedding')
++
+ objcopy_supports_add_symbol = false
+ objcopy = find_program('objcopy', required : false)
+ if objcopy.found()
+   objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol')
+ endif
++fast_gresource_embedding = fast_gresource_embedding and objcopy_supports_add_symbol
+ ld = find_program('ld', required : false)
++fast_gresource_embedding = fast_gresource_embedding and ld.found()
++
++if meson.is_cross_build() or build_machine.system() != 'linux'
++  fast_gresource_embedding = false
++endif
++
++if build_machine.cpu_family() in ['arm', 'mips']
++  # Known not to work reliably on these architectures
++  fast_gresource_embedding = false
++endif
+-if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
++if fast_gresource_embedding
+   glib_compile_resources = find_program('glib-compile-resources')
+   # Create the resource blob
+diff --git a/meson_options.txt b/meson_options.txt
+index 2084ab8..078e76f 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -78,6 +78,11 @@ option('f16c',
+        value: 'enabled',
+        description: 'Enable F16C fast paths (requires F16C)')
++option('fast_gresource_embedding',
++       type: 'boolean',
++       value: true,
++       description: 'Speed up GResource compilation (does not work on all architectures)')
++
+ # Documentation and introspection
+ option('gtk_doc',
index 018c40f4183f890cdae90daa7ea06873c80206b4..2fcc607beae9c48575a4014f38da508236268ed2 100644 (file)
@@ -1,3 +1,4 @@
+build-Add-an-option-to-use-more-conservative-GResource-em.patch
 reftest_compare_surfaces-Report-how-much-the-images-diffe.patch
 reftests-Allow-minor-differences-to-be-tolerated.patch
 debian/Disable-clipboard-test.patch
index 3e7cbb2bc1353621b6d1df9c635f07865e1a91d8..f9625327251dc7cb61ec3646e3ef9ea0cf210a5d 100755 (executable)
@@ -76,6 +76,7 @@ debian/%: debian/%.in
 
 configure_flags_common = \
        --libdir=/$(LIBDIR) \
+       -Dfast_gresource_embedding=false \
        ${NULL}
 
 configure_flags_deb = \